<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/uploads/panda2.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/uploads/panda2.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/uploads/panda2.png?v=6.3.0">










<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '6.3.0',
    sidebar: {"position":"left","display":"hide","offset":12,"b2t":false,"scrollpercent":false,"onmobile":true},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="前言：我们知道，当发生点击事件时，系统通过 - (UIView )hitTest:(CGPoint)point withEvent:(UIEvent )event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。以下分析系统如何实现的，这是demo   数字对应的是该View的tag，以下实现中均点击tag为104的View   首先我们观察系统的打印结果，在- (U">
<meta property="og:type" content="article">
<meta property="og:title" content="分析系统查找第一响应者的过程实现">
<meta property="og:url" content="adoma.cn/04252017.html">
<meta property="og:site_name" content="Adoma.cn">
<meta property="og:description" content="前言：我们知道，当发生点击事件时，系统通过 - (UIView )hitTest:(CGPoint)point withEvent:(UIEvent )event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。以下分析系统如何实现的，这是demo   数字对应的是该View的tag，以下实现中均点击tag为104的View   首先我们观察系统的打印结果，在- (U">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1489803-8447d0e7cf3f8464.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2017-04-26T02:35:51.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="分析系统查找第一响应者的过程实现">
<meta name="twitter:description" content="前言：我们知道，当发生点击事件时，系统通过 - (UIView )hitTest:(CGPoint)point withEvent:(UIEvent )event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。以下分析系统如何实现的，这是demo   数字对应的是该View的tag，以下实现中均点击tag为104的View   首先我们观察系统的打印结果，在- (U">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/1489803-8447d0e7cf3f8464.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">






  <link rel="canonical" href="adoma.cn/04252017.html"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>分析系统查找第一响应者的过程实现 | Adoma.cn</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Adoma.cn</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>

      
      
    </ul>
  

  
    

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="adoma.cn/04252017.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/panda2.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Adoma.cn">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">分析系统查找第一响应者的过程实现
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2017-04-25 21:41:31" itemprop="dateCreated datePublished" datetime="2017-04-25T21:41:31+08:00">2017-04-25</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2017-04-26 10:35:51" itemprop="dateModified" datetime="2017-04-26T10:35:51+08:00">2017-04-26</time>
              
            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/04252017.html#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/04252017.html" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/04252017.html" class="leancloud_visitors" data-flag-title="分析系统查找第一响应者的过程实现">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数：</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h5 id="前言：我们知道，当发生点击事件时，系统通过-UIView-hitTest-CGPoint-point-withEvent-UIEvent-event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。"><a href="#前言：我们知道，当发生点击事件时，系统通过-UIView-hitTest-CGPoint-point-withEvent-UIEvent-event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。" class="headerlink" title="前言：我们知道，当发生点击事件时，系统通过 - (UIView )hitTest:(CGPoint)point withEvent:(UIEvent )event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。"></a>前言：我们知道，当发生点击事件时，系统通过 <em>- (UIView <em>)hitTest:(CGPoint)point withEvent:(UIEvent </em>)event</em>查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。</h5><h4 id="以下分析系统如何实现的，这是demo"><a href="#以下分析系统如何实现的，这是demo" class="headerlink" title="以下分析系统如何实现的，这是demo"></a>以下分析系统如何实现的，<a href="https://github.com/ad0ma/-hitTest-TouchBegin" target="_blank" rel="noopener">这是demo</a></h4><hr>
<p><img src="http://upload-images.jianshu.io/upload_images/1489803-8447d0e7cf3f8464.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
<blockquote>
<p>数字对应的是该View的tag，以下实现中均点击tag为104的View</p>
</blockquote>
<ul>
<li><p>首先我们观察系统的打印结果，在<strong>- (UIView <em>)hitTest:(CGPoint)point withEvent:(UIEvent </em>)event</strong>中添加如下代码</p>
<figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="built_in">UIView</span> *)hitTest:(<span class="built_in">CGPoint</span>)point withEvent:(<span class="built_in">UIEvent</span> *)event</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">NSLog</span>(<span class="string">@"hit start -- &gt;%ld"</span>,<span class="keyword">self</span>.tag);</span><br><span class="line">    <span class="built_in">UIView</span> *v = [<span class="keyword">super</span> hitTest:point withEvent:event];</span><br><span class="line">    <span class="built_in">NSLog</span>(<span class="string">@"hit end %ld -&gt;%@"</span>,<span class="keyword">self</span>.tag,v);</span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>打印结果如下</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">hit start -- &gt;<span class="number">100</span></span><br><span class="line">hit start -- &gt;<span class="number">101</span></span><br><span class="line">hit end <span class="number">101</span> -&gt;(null)</span><br><span class="line">hit start -- &gt;<span class="number">102</span></span><br><span class="line">hit start -- &gt;<span class="number">104</span></span><br><span class="line">hit end <span class="number">104</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">102</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">100</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line">hit start -- &gt;<span class="number">100</span></span><br><span class="line">hit start -- &gt;<span class="number">101</span></span><br><span class="line">hit end <span class="number">101</span> -&gt;(null)</span><br><span class="line">hit start -- &gt;<span class="number">102</span></span><br><span class="line">hit start -- &gt;<span class="number">104</span></span><br><span class="line">hit end <span class="number">104</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">102</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">100</span> -&gt;&lt;TestView: <span class="number">0x7fb3a1f8ef80</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fb3a1f87190</span>&gt;&gt;</span><br><span class="line"><span class="number">104</span> -&gt;-[TestView touchesBegan:withEvent:]</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>-</p>
<ul>
<li><p>下面是我模仿系统实现的方法</p>
<figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="built_in">UIView</span> *)__adHitTest:(<span class="built_in">CGPoint</span>)point withEvent:(<span class="built_in">UIEvent</span> *)event</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">if</span> (![<span class="keyword">self</span> pointInside:point withEvent:event]) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">nil</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">self</span>.userInteractionEnabled == <span class="literal">NO</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">nil</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">self</span>.alpha &lt; <span class="number">0.01</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">nil</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">self</span>.hidden == <span class="literal">YES</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">nil</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">self</span>.subviews.count) &#123;</span><br><span class="line">        </span><br><span class="line">        <span class="keyword">for</span> (<span class="built_in">NSUInteger</span> i = <span class="keyword">self</span>.subviews.count; i &gt; <span class="number">0</span>; i--) &#123;</span><br><span class="line">        </span><br><span class="line">            <span class="built_in">UIView</span> *sub = <span class="keyword">self</span>.subviews[i<span class="number">-1</span>];</span><br><span class="line">            </span><br><span class="line">            <span class="built_in">CGPoint</span> p = [<span class="keyword">self</span> convertPoint:point toView:sub];</span><br><span class="line">            </span><br><span class="line">            <span class="built_in">UIView</span> *t = [sub hitTest:p withEvent:event];</span><br><span class="line">            </span><br><span class="line">            <span class="keyword">if</span> (t != <span class="literal">nil</span>) &#123;</span><br><span class="line">                <span class="keyword">return</span> t;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">self</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>在 <strong>- (UIView <em>)hitTest:(CGPoint)point withEvent:(UIEvent </em>)event</strong> 换成模仿的实现</p>
<figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="built_in">UIView</span> *)hitTest:(<span class="built_in">CGPoint</span>)point withEvent:(<span class="built_in">UIEvent</span> *)event</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">NSLog</span>(<span class="string">@"hit start -- &gt;%ld"</span>,<span class="keyword">self</span>.tag);</span><br><span class="line">    <span class="built_in">UIView</span> *v = [<span class="keyword">self</span> __adHitTest:point withEvent:event];</span><br><span class="line">    <span class="built_in">NSLog</span>(<span class="string">@"hit end %ld -&gt;%@"</span>,<span class="keyword">self</span>.tag,v);</span><br><span class="line">    <span class="keyword">return</span> v;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>观察模仿后的打印结果</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">hit start -- &gt;<span class="number">100</span></span><br><span class="line">hit start -- &gt;<span class="number">101</span></span><br><span class="line">hit end <span class="number">101</span> -&gt;(null)</span><br><span class="line">hit start -- &gt;<span class="number">102</span></span><br><span class="line">hit start -- &gt;<span class="number">104</span></span><br><span class="line">hit end <span class="number">104</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">102</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">100</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line">hit start -- &gt;<span class="number">100</span></span><br><span class="line">hit start -- &gt;<span class="number">101</span></span><br><span class="line">hit end <span class="number">101</span> -&gt;(null)</span><br><span class="line">hit start -- &gt;<span class="number">102</span></span><br><span class="line">hit start -- &gt;<span class="number">104</span></span><br><span class="line">hit end <span class="number">104</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">102</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line">hit end <span class="number">100</span> -&gt;&lt;TestView: <span class="number">0x7fd22ac1d680</span>; frame = (<span class="number">29</span> <span class="number">89</span>; <span class="number">176</span> <span class="number">61</span>); autoresize = RM+BM; tag = <span class="number">104</span>; layer = &lt;<span class="built_in">CALayer</span>: <span class="number">0x7fd22ac1d7f0</span>&gt;&gt;</span><br><span class="line"><span class="number">104</span> -&gt;-[TestView touchesBegan:withEvent:]</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="是不是差不多？"><a href="#是不是差不多？" class="headerlink" title="是不是差不多？"></a>是不是差不多？</h3>
      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/07062017.html" rel="prev" title="swift的group类型tableView的诡异问题">
                swift的group类型tableView的诡异问题 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/uploads/panda2.png"
                alt="" />
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">6</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              

              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/ad0ma" target="_blank" title="GitHub" rel="external nofollow"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="http://www.jianshu.com/u/6ef33e9adf4f" target="_blank" title="简书" rel="external nofollow"><i class="fa fa-fw fa-book"></i>简书</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-5"><a class="nav-link" href="#前言：我们知道，当发生点击事件时，系统通过-UIView-hitTest-CGPoint-point-withEvent-UIEvent-event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。"><span class="nav-number">1.</span> <span class="nav-text">前言：我们知道，当发生点击事件时，系统通过 - (UIView )hitTest:(CGPoint)point withEvent:(UIEvent )event查找第一响应者。找到之后触发该响应者的UIResponder中的touch方法。</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#以下分析系统如何实现的，这是demo"><span class="nav-number"></span> <span class="nav-text">以下分析系统如何实现的，这是demo</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#是不是差不多？"><span class="nav-number"></span> <span class="nav-text">是不是差不多？</span></a></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder"></span>

  

  
</div>


  










        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



  





  








<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>


<script src="//unpkg.com/valine/dist/Valine.min.js"></script>

  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(function (item) {
      return GUEST.indexOf(item)>-1;
  });
    new Valine({
      el: '#comments' ,
        verify: true,
        notify: true,
        appId: 'w2OKDPpivwCEYD0HDt6bn6uC-gzGzoHsz',
        appKey: 'TJ4chhFWUYidIIIkUWYAVfYU',
        placeholder: '你想说什么？',
        avatar:'mm',
    meta:guest,
        pageSize:'10' || 10,
        visitor: true
    });
  </script>
  <script type="text/javascript">
    $('.info').css({
      'display' : 'none'
  })
  $('.col.col-20').css({
      'display' : 'none'
  })
  </script>



  





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  
  

  

  

  

  

  
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('复制').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        
          if(result)$(this).text('复制成功')
          else $(this).text('复制失败')
        
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('复制')
        }, 300)
      }).append(e)
    })
  </script>


</body>
</html>
